<extend name="Public:index" />
<block name="mycss">

</block>
<block name="main-content">
    <iframe name="ajaxifr" style="display:none;"></iframe>
	<div class="container-fluid">
         <div class="row">
		   <volist name="modules" id="vo" mod="4">
			<div class="col-lg-3">
				<div class="card">
					<div class="card-body">
						<div class="pricingTable1">
							<h6 class="title1 p-2 mt-2 mb-0">
                            <a href="#" data-toggle="modal" data-target="#editModal" data-backdrop="static" data-id="{$vo.id}">{$vo.name} </a>
                             <a class="btn float-right btn-light btn-sm" onclick="delBlock({$vo.id});"><i class="far fa-trash-alt"></i></a>
                            </h6>
							<p class="text-muted p-2 mb-0">{$vo.dec}</p>
							<ul class="list-unstyled pricing-content-2 pb-3"> 
								<li>{$vo.tp_count}种设备类型</li>
								<li>{$vo.tpp_count}个点位设计</li>

							</ul>
							<div class="text-center">
								<!-- <h3 class="amount">$39.00<small class="font-12 text-muted">/month</small></h3> -->
							</div>
							<a data-url="{:U('Web/block/template')}" href="{:U('Web/block/template',array('module_id'=>$vo[id]))}" class="pricingTable-signup mt-3">配置</a>
						</div>
						<!--end pricingTable-->
					</div>
					<!--end card-body-->
				</div>
				<!--end card-->
			</div>
			<!--end col-->
            <eq name="mod" value="3"></div><div class="row"></eq>
            </volist>
         </div>
           
         <div class="row">
            <div class="col-sm-12">
                <div class="mb-4">
                    <button class="btn btn-info px-4 align-self-center waves-effect report-btn" data-toggle="modal" data-target="#editModal" data-backdrop="static" >
                        <i class="mdi  mdi-plus"></i>
                        创建模块</button>

                </div>
                <!--end page title box-->
            </div>
            <!--end col-->

        </div> 
        <div class="modal fade" id="editModal" tabindex="-1" role="dialog" aria-labelledby="editModal" aria-hidden="true">
        <div class="modal-dialog modal-lg" role="document">
            <form class="" method="post" action="{:U('editBlock')}" target="ajaxifr">
                <div class="modal-content">
                </div>
            </form>
        </div>
    </div> 
         

	</div><!-- container -->
</block>
<block name="myscript">
 <script>
    $('#editModal').on('show.bs.modal', function (e) {

        var obj = $(e.relatedTarget);
        var id = obj.data('id'); 
        var url = "{:U('editBlock','','')}/id/" + id;
        $.ajax({
            type: 'GET',
            url: url
        }).then(function (data) {
            $('.modal-content').html(data);

        });
    });
    function delBlock(id){
            var url = "{:U('delBlock')}";
            if(confirm("确认删除此模块吗？")){
                $.get(url, {id: id}, function(res){
                    if(res == '1'){
                        window.location.reload();
                    }
                });
            }
        }

      
    </script>
</block>